package com.zx.util;

import com.zx.model.user.User;

import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;

/**
 * @author sunkai
 * @date 2022/8/3 0003 17:47
 * @mood zhou xun
 */
public class CookieUtil {

    public static User queryCookie(HttpServletRequest request) {
        Cookie[] cookies = request.getCookies();
        for (Cookie cookie : cookies) {
            String name = cookie.getName();
            if (name.equals(MallConstant.TOKEN)) {
                String value = cookie.getValue();
                return MallConstant.MAP.get(value);
            }
        }
        return null;
    }

}
